package com.xintai.approval.service.impl;

import java.util.List;

import com.xintai.approval.Utils.CommitUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xintai.approval.mapper.FlowCaigouApplyMapper;
import com.xintai.approval.domain.FlowCaigouApply;
import com.xintai.approval.service.IFlowCaigouApplyService;

/**
 * 采购申请单
 Service业务层处理
 *
 * @author xintai
 * @date 2021-02-03
 */
@Service
public class FlowCaigouApplyServiceImpl implements IFlowCaigouApplyService
{
    @Autowired
    private FlowCaigouApplyMapper flowCaigouApplyMapper;

    /**
     * 查询采购申请单

     *
     * @param id 采购申请单
    ID
     * @return 采购申请单

     */
    @Override
    public FlowCaigouApply selectFlowCaigouApplyById(Long id)
    {
        return flowCaigouApplyMapper.selectFlowCaigouApplyById(id);
    }

    /**
     * 查询采购申请单
     列表
     *
     * @param flowCaigouApply 采购申请单

     * @return 采购申请单

     */
    @Override
    public List<FlowCaigouApply> selectFlowCaigouApplyList(FlowCaigouApply flowCaigouApply)
    {
        return flowCaigouApplyMapper.selectFlowCaigouApplyList(flowCaigouApply);
    }

    /**
     * 新增采购申请单

     *
     * @param flowCaigouApply 采购申请单

     * @return 结果
     */
    @Override
    public Long insertFlowCaigouApply(FlowCaigouApply flowCaigouApply)
    {
        String[] caigouType = flowCaigouApply.getArrCaigou();
        String s = CommitUtils.arrToStr(caigouType);
        flowCaigouApply.setCaigouType(s);
        flowCaigouApplyMapper.insertFlowCaigouApply(flowCaigouApply);
        return flowCaigouApply.getId();
    }

    /**
     * 修改采购申请单

     *
     * @param flowCaigouApply 采购申请单

     * @return 结果
     */
    @Override
    public int updateFlowCaigouApply(FlowCaigouApply flowCaigouApply)
    {
        return flowCaigouApplyMapper.updateFlowCaigouApply(flowCaigouApply);
    }

    /**
     * 批量删除采购申请单

     *
     * @param ids 需要删除的采购申请单
    ID
     * @return 结果
     */
    @Override
    public int deleteFlowCaigouApplyByIds(Long[] ids)
    {
        return flowCaigouApplyMapper.deleteFlowCaigouApplyByIds(ids);
    }

    /**
     * 删除采购申请单
     信息
     *
     * @param id 采购申请单
    ID
     * @return 结果
     */
    @Override
    public int deleteFlowCaigouApplyById(Long id)
    {
        return flowCaigouApplyMapper.deleteFlowCaigouApplyById(id);
    }
}
